package com.bristua.mall.user.controller;

import com.bristua.mall.common.bean.Result;
import com.bristua.mall.common.enums.CommonCode;
import com.bristua.mall.common.utils.CacheUtil;
import com.bristua.mall.common.utils.HandleResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by Administrator on 2019/5/9.
 */
@RestController
@Api(value="用户注销",tags={"用户注销"})
public class UserLogoutController {

    @Autowired
    private CacheUtil cacheUtil;

    @ApiOperation(value="用户注销")
    @PostMapping(value="/api/user/logout")
    public Result userLogout(HttpServletRequest request){
        String token = request.getHeader("token");
        cacheUtil.remove(token);
        return HandleResultUtil.commonResult(CommonCode.CANCEL_SUCCESS.getCode(),CommonCode.CANCEL_SUCCESS.getMsg());
    }
}
